package com.wordplat.quickstart.mvp;

import com.wordplat.quickstart.ResourceTable;
import com.wordplat.quickstart.app.AppRuntime;
import com.wordplat.quickstart.utils.ToastViewDialog;
import com.wordplat.quickstart.xutils.common.util.TextUtils;

/**
 * <p>BaseViewListener</p>
 * <p>Date: 2017/5/15</p>
 *
 * @author afon
 * @since 2017-04-11
 */
public class BaseViewListener implements BaseView {
    @Override
    public void onNoNetworkError(int requestCode) {
        ToastViewDialog.toast(AppRuntime.getsContext(), AppRuntime.getsContext().getString(
                ResourceTable.String_Warning_No_Network));
    }

    @Override
    public void onNetworkTimeOutError(int requestCode) {
        ToastViewDialog.toast(AppRuntime.getsContext(), AppRuntime.getsContext().getString(
                ResourceTable.String_Warning_Network_Timeout));
    }

    @Override
    public void onSuccess(int requestCode) {

    }

    @Override
    public void onResultParseError(int requestCode) {

    }

    @Override
    public void onResultFailed(int requestCode, int errCode, String errMessage) {
        if (!TextUtils.isEmpty(errMessage)) {
            ToastViewDialog.toast(AppRuntime.getsContext(), errMessage);
        }
    }

    @Override
    public void onResultEmpty(int requestCode) {

    }

    @Override
    public void onShowWarning(int requestCode, int errMessageResId) {
        ToastViewDialog.toast(AppRuntime.getsContext(), AppRuntime.getsContext().getString(errMessageResId));
    }
}
